<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" href="../style/journal.css" type="text/css" />
<style type="text/css"><!--
.googleadsense {
	margin: 2px;
	padding: 0px;
//--></style><script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-65008-1";
urchinTracker();
</script><title>用Module::Build制作CPAN模块包</title>
</head>
<body>
<a href="index.html">Journal</a>(2005) | <a href="../blog/"><b>Blog</b></a>(2006) | <a href="http://www.fayland.org/cgi-bin/random_link.pl">RandomLink</a> | <a href="AboutFayland.html">WhoAmI</a> | <a href="LiveBookmark.html">LiveBookmark</a> | <a href="http://www.fayland.org/">HomePage</a>
<p><&lt;Previous: <a href="Win32.html">Perl in Win32</a>&nbsp;&nbsp;>>Next: <a href="FayGuestBook.html">FayGuestBook</a></p>
<h1>用Module::Build制作CPAN模块包</h1>
<div class='content'>
<p>Category: <a href='Modules.html'>Modules</a> &nbsp; Keywords: <b>Module::Build CPAN</b></p><h2>Problem</h2>
想将<a href='Han2PinYin.html'>Lingua::Han2PinYin</a>传到CPAN上。<br>
在传到CPAN之前得先制作可安装的Lingua-Han2PinYin-0.01.tar.gz<br>
在Win32下用<a href='http://search.cpan.org/perldoc?ExtUtils::MakeMaker'>ExtUtils::MakeMaker</a>总不成功。然后就到处去找帖子看别人是怎么上传模块到CPAN的。<br>
后来在<a href='http://www.perl.com/pub/a/2003/02/12/module1.html'>http://www.perl.com/pub/a/2003/02/12/module1.html</a>找到“Module::Build”，耐着性子看完了。按照操作弄弄竟然也成功了。

<h2>Solution</h2>
不想翻译那篇长文，写写自己的操作过程。<br>
<ol>
<li>cpan Module::Build<br>
安装Module::Build模块
<li>写Build.PL
<pre>use Module::Build;

Module::Build->new(
    create_makefile_pl => 'passthrough',
    module_name => 'Lingua::Han2PinYin',
    license => 'perl',
)->create_build_script;
</pre>
<li>上面的 create_makefile_pl => 'passthrough', 会自动生成 Makefile.PL
<li>将Han2PinYin.pm放到当前文件夹的lib/Lingua下。
<li>cmd
<pre>C:>perl Build.PL
C:>perl Build
C:>perl Build manifest
C:>perl Build dist
C:>perl Build realclean
</pre>
</ol>
到此，文件夹里就会生成Lingua-Han2PinYin-0.01.tar.gz。差不多就这样。很easy的。

<h2>Refer/参考</h2>
<ul>
<li><a href='http://www.perl.com/pub/a/2003/02/12/module1.html'>Perl.com Module::Build</a>
<li><a href='http://search.cpan.org/perldoc?Module::Build'>Perldoc Module::Build</a>
</ul></div>
<p><&lt;Previous: <a href="Win32.html">Perl in Win32</a>&nbsp;&nbsp;>>Next: <a href="FayGuestBook.html">FayGuestBook</a></p>
<p><strong>Options:</strong> <a href='http://del.icio.us/post?title=%E7%94%A8Module::Build%E5%88%B6%E4%BD%9CCPAN%E6%A8%A1%E5%9D%97%E5%8C%85&url=http://www.fayland.org/journal/Module_Build.html'>+Del.icio.us</a></p>
<strong>Related items</strong>
<ul><li><a href='050315.html'>rt.cpan.org: Bug</a> < <span class='digit'>2005-03-15 22:18:50</span> ></li><li><a href='minicpan.html'>如何用 minicpan 映像自己的 CPAN</a> < <span class='digit'>2005-04-07 22:14:38</span> ></li><li><a href='CPAN_update.html'>CPAN RSS updated</a> < <span class='digit'>2005-11-13 20:58:31</span> ></li><li><a href='CPANPLUS_Tester.html'>be a CPANPLUS Tester</a> < <span class='digit'>2005-12-09 16:35:07</span> ></li><li><a href='Date_Holidays_CN.html'>检测中国的假期模块</a> < <span class='digit'>2005-12-20 15:00:51</span> ></li><li><a href='CPAN_Contributor.html'>写模块给 CPAN 要注意的地方</a> < <span class='digit'>2005-12-21 14:14:33</span> ></li></ul>
Created on <span class="digit">2004-12-16 18:59:50</span>, Last modified on <span class="digit">2005-06-01 22:23:57</span><br />
Copyright 2004-2005 All Rights Reserved. Powered by <a href="Eplanet.html">Eplanet</a> && <a href='http://catalyst.perl.org'>Catalyst</a> 5.62.
</body>
</html>